//
//  NSArray+DLArrayExtension.m
//  FRP_OC
//
//  Created by meitianhui2 on 2017/12/11.
//  Copyright © 2017年 YiXue. All rights reserved.
//

#import "NSArray+DLArrayExtension.h"

typedef void (^DLEnumerateHandler)(id item);

@implementation NSArray (DLArrayExtension)

- (DLArrayMap)map
{
    //
    DLArrayMap map = ^id(DLItemMap itemMap){
        NSMutableArray *items = @[].mutableCopy;
        for (id item in self) {
            [items addObject:itemMap(item)];
        }
        return items;
    };
    return map;
}

- (void)setMap:(DLArrayMap)map
{
    
}

- (DLArrayFilter)filter
{
    DLArrayFilter filter = ^(DLItemFilter itemFilter) {
        NSMutableArray * items = [NSMutableArray array];
        for (id item in self) {
            // 返回 itemFilter(item)
            if (itemFilter(item)){
                [items addObject: item];
            }
        }
        return items;
    };
    
    return filter;
}

// 设置 filter
- (void)setFilter:(DLArrayFilter)filter
{
    
}


@end
